<?php
// 总后台控制台

namespace app\console\controller;

use think\Cache;
use think\Db;
use think\Controller;

class Dashboard extends Controller
{

    /**
     * 控制台主页
     */
    public function index()
    {
        // 最新注册会员
        Db::name('member')->order(['id' => 'desc'])->limit('5')->cache('index_member', 300)->select();

        // 最新订单信息
        Db::name('order')->where(['status' => ['in', '2,5,6']])
            ->field('id,shop_order_number,DATE_FORMAT(create_time,"%Y-%m-%d %H:%i:%s") create_time,amount price,status')->limit('5')->order('create_time','desc')->cache('index_order', 1)->select();

        // 最新充值提现记录
        Db::name('member_withdraw')->where(['type_id' => ['in', '1,2'], 'status' => '1'])
            ->field('id,price,type_id,order_number,create_time')->order(['id' => 'desc'])->limit('5')->cache('index_withdraw', 300)->select();


        return $this->fetch('', [
            'mate_title' => '控制台'
        ]);
    }
}